#ifndef LHC_UTILITIES_H_INCLUDED_
#define LHC_UTILITIES_H_INCLUDED_

#include "Endian.h"
#include <boost/cstdint.hpp>
#include <cstddef>

namespace lhcutils
{

// Converts the bytes in the given vector at the given offset (default 0) to a T.
// T should be a built-in type.
template<typename T>
T GetFromBytes(const uint8_t* bytes, Endianness::Value endianness);

// Appends the bytes of data to the given vector. T should be a built-in type
template<typename T>
void AppendBytes(std::vector<uint8_t>& vec, T data, Endianness::Value endianness);

// Returns the status of the bit at the given bit index in number (true for set, false for unset).
// T should be a built-in type.
template<typename T>
bool GetBit(T number, unsigned int bitIndex);


template<typename T>
struct CountedArray
{
public:
	T* Ptr;
	std::size_t Count;
};

}


#include "utilities.impl.h" // template implementation

#endif

/*
 Copyright 2011 Greg Najda

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
